import { httpClient } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';

/** 权限模块URL枚举 */
enum Api {
  /** 检查URL授权 */
  CheckUrlAuth = '/api/auth/checkurlauth',
  /** 获取授权信息 */
  GetAuthInfo = '/api/auth/getauthinfo',
}

/**
 * 检查URL授权
 * @param url 要检查的URL
 * @param mode 错误消息模型
 */
export function checkUrlAuth(url: string, mode: ErrorMessageMode = 'none') {
  return httpClient.get<boolean>(
    {
      url: Api.CheckUrlAuth,
      params: { url: url },
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 获取授权信息
 * @param mode 错误消息模型
 */
export function getAuthInfo(mode: ErrorMessageMode = 'none') {
  return httpClient.get<string[]>(
    {
      url: Api.GetAuthInfo,
    },
    {
      errorMessageMode: mode,
    },
  );
}
